<?php

Framework::needsToImplement("FormInterface");
Framework::needsToImplement("FormComponent");
Framework::needsToImplement("ICodeInterface");
Framework::needsToImplement("IWCDefaults");
Framework::needs("engine.Render");
Render::addJSDependencies('hibrid_javascript/iwc-forms/InputText.js');


class InputText implements FormInterface, FormComponent, ICodeInterface, IWCDefaults {
	private $id;
	private $validation;
	private $length;
	private $fieldsize;
	private $readonly=false;
	private $class;
	private $value;
	private $icode;
	private $height;
	private $width;
	private $disabled=false;
	private $tips;
	/**
	 * @return unknown
	 */
	public function getFieldsize() {
		return $this->fieldsize;
	}
	
	/**
	 * @return unknown
	 */
	public function getHeight() {
		return $this->height;
	}
	
	/**
	 * @return unknown
	 */
	public function getReadonly() {
		return $this->readonly;
	}
	
	/**
	 * @return unknown
	 */
	public function getTips() {
		return $this->tips;
	}
	
	/**
	 * @return unknown
	 */
	public function getWidth() {
		return $this->width;
	}
	
	/**
	 * @param unknown_type $fieldsize
	 */
	public function setFieldsize($fieldsize) {
		$this->fieldsize = $fieldsize;
	}
	
	/**
	 * @param unknown_type $readonly
	 */
	public function setReadonly($readonly) {
		$this->readonly = $readonly;
	}
	
	/**
	 * @param unknown_type $tips
	 */
	public function setTips($tips) {
		$this->tips = $tips;
	}

	
	public function disabled($status) {
		$disabled=$status;
	}
	public function __construct($id=null) {
		$this->id=$id;
		$this->icode=Array(
			'id'=>'setId',
			'class'=>'setClass',
			'value'=>'setValue',
			'validation'=>'validation',
			'readonly'=>'readonly',
			'size'=>'setFieldSize'
		);
	}
	public function getCSSHDeps() {
		return null;
	}
	public function getCSSTDeps() {
		return null;
	}
	public function getId() {
		return $this->id;
	}
	public function getJSHDeps() {
		return Array('iwc-forms/InputText.js');
	}
	public function getJSTDeps() {
		return Array('prototype.js');
	}
	public function setSize($len) {
		$this->length=$len;
	}
	public function setId($id) {
		$this->id=$id;
	}
	public function setWidth($width) {
		$this->width=$width;
	}
	public function setHeight($height) {
		$this->height=$width;
	}
	public function show() {
		echo $this->__toString();
	}
	public function __getJSValidation($message) {
		$this->message=$message;
		return "iwc.forms.InputText.getValue('".$this->id."','".$message."')";
	}
	public function __getJSValue() {
		return "iwc.forms.InputText.validation('".$this->id."')";
	}
	public function __toString() {
		return 	'<input type="text" id="'.$this->id.
			   	'" class="'.$this->class.'"'.
				(($this->readonly)?' readonly="true" ':'').
				(($this->disabled)?' disabled="true" ':'').
				' value="'.$this->value.'"'.
				' size="'.$this->fieldsize.'"'.
			   	' />';
	}
	public function readOnly($status){
		$this->readonly=$status;	
	}
	public function getClass(){
		return $this->class;
	}
	public function setClass($class) {
		$this->class=$class;
	}
	public function icodeSupportedProperties(){
		return $this->icode;
	}
	public function setTitle($title) {
		
	}
	public function setStyle($style) {
		$this->style=$style;
	}
	public function getStyle() {
		return $this->style;
	}
	public function icodeSet($prop,$value){
		if(isset($this->icode[$prop])) {
				$op=$this->icode[$prop];
				$this->$op($value);			
		}
	}
	public function setValue($value){
		$this->value=$value;
	}
	public function getValue(){
		return $this->value;
	}
}

?>
